import {hrAjax as proFetch} from 'src/hrpub/common/utils/utils';
import {promptBox, toast} from 'nc-lightapp-front';

export default function checkOpinionMsg(callback) {
    const {json, orgVal} = this.props;
    const checkedData = this.props.editTable.getCheckedRows('contopiniongrid');
    if (!checkedData.length) {
        toast({color: 'warning', content: json['cm6011-000106']}); /* 国际化处理： 请选择要删除的条目!*/
        return;
    }

    let param = {
        pk_org: orgVal.refpk,
        sendCheck: "Y",
        contopiniongrid: {
            rows: checkedData.map(item => item.data)
        }
    };

    return proFetch({
        url: '/nccloud/hrcm/contopinion/OpinionRemcSendMsgAction.do',
        body: param
    }).then((res) => {
        if (res.success) {
            if (res.data) {
                promptBox({
                    color: 'warning',
                    title: json['cm6011-000056'], // 确认
                    content: res.data, // 是否
                    beSureBtnClick: () => {
                        callback && callback();
                    }
                });
            } else {
                callback && callback();
            }
        }
    });
}
